# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from ragendja.template import render_to_response

def staff_only(view):
    """
    Decorator that requires user.is_staff. Otherwise renders no_access.html.
    """
    @login_required
    def wrapped(request, *args, **kwargs):
        if request.user.is_active and request.user.is_staff:
            return view(request, *args, **kwargs)
        return render_to_response(request, 'no_access.html')
    return wrapped
